/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lenovo
 * Date: 2025-08-16
 * Time: 2:30
 */
//https://leetcode.cn/problems/longest-substring-without-repeating-characters/
public class Test {
    public static int lengthOfLongestSubstring(String s) {
        char[] arr=s.toCharArray();
        int[] hash=new int[128];
        int len=arr.length;
        int max=0;
        int n=0;
        for(int p1=0,p2=0;p2<len;p2++){
            while(hash[arr[p2]]>0){
                hash[arr[p1++]]--;
                n--;
            }
            hash[arr[p2]]++;
            n++;
            max=Math.max(max,n);
        }
        return max;
    }
    public static void main(String[] args) {
        String str="awd h1iuy2e3adkjhc";
        System.out.println(lengthOfLongestSubstring(str));
    }
}
